﻿using System;
using System.Collections.Generic;
using System.Linq;
using DC2010.Objects.Base;

namespace DC2010.Objects.Data
{
    [Serializable]
    public class FloorData : BaseData
    {
		public FloorData()
		{
            //Point StartPosition = new Point(0, 0);
			
			// there are several predefined layers
			
            //// Tiles
            //Layer lTiles = new Layer(BaseObjectType.Tile);
			
            //// Item on floor
            //Layer lItems = new Layer(BaseObjectType.Item);
			
            ////Party generally means monsters. Every monster must be in party.
            //Layer lParty = new Layer(BaseObjectType.Party);
			
            ////Door for current layer
            //Layer lDoors = new Layer(BaseObjectType.Door);

            Layers = new List<Layer>();
            TileLayer = new Layer();
            TileLayer.Type = BaseObjectType.Tile;
			
            //Layers.Add(lTiles);
            //Layers.Add(lItems);
            //Layers.Add(lParty);
            //Layers.Add(lDoors);		
		}
	    /// <summary>
        /// Every map consists of several map floors. Each floor can be understand as one floor in game.
		/// each floor is created with several layers.
        /// </summary>		
        public List<Layer> Layers { get; set; }	

        public Layer TileLayer {get;set;}
        //{
        //    get
        //    {
        //        var x = (from i in Layers
        //                 where i.Type == BaseObjectType.Tile
        //                 select i).FirstOrDefault();

        //        return x;
        //    }
        //}
		
        public FloorGfx Gfx
        {
            get
            {
                if (!string.IsNullOrEmpty(GfxId))
                {
                    return Root.I.FloorSystem.GetGfx(GfxId);
                }

                return null;
            }
        }			
		
        private FloorLogic _l;
        public FloorLogic L
        {
            get
            {
                if (_l == null)
                    _l = new FloorLogic(this);

                return _l;
            }
        }
    }
}
